package com.cynteka.cyfoman.core.collection;

/**
 * User: Sergey
 * Date: 29.07.11
 * Time: 12:07
 */
public enum ConnectionLinkType {
    ONE(1),
    MANY(Integer.MAX_VALUE);

    public final int number;

    ConnectionLinkType(int number) {
        this.number = number;
    }

    public static ConnectionLinkType getType(int number) {
        if (number < 0)
            throw new IllegalArgumentException("Argument cannot be less then 0");
        if (number <= 1)
            return ONE;
        return MANY;
    }

    public boolean check(int number) {
        if (number < 0) {
            return false;
        }
        if (this == ONE && number > 1) {
            return false;
        }
        return true;
    }
}
